Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/112315.diff

1 Files Affected:

  • (modified) lldb/source/Commands/CommandObjectMultiword.cpp (+1-10)
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..8e9f91c64140ea 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -84,16 +84,7 @@ bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
     lldbassert((&GetCommandInterpreter() == &cmd_obj_sp->GetCommandInterpreter()) &&
            "tried to add a CommandObject from a different interpreter");
 
-  CommandMap::iterator pos;
-  bool success = true;
-
-  pos = m_subcommand_dict.find(std::string(name));
-  if (pos == m_subcommand_dict.end()) {
-    m_subcommand_dict[std::string(name)] = cmd_obj_sp;
-  } else
-    success = false;
-
-  return success;
+  return m_subcommand_dict.try_emplace(std::string(name), cmd_obj_sp).second;
 }
 
 llvm::Error CommandObjectMultiword::LoadUserSubcommand(

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit a7b7af7 into llvm:main Oct 15, 2024
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lldb branch October 15, 2024 14:37
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants